import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import './style.css'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 确保所有需要的图标都被注册
const requiredIcons = [
  'Monitor',
  'Goods',
  'ShoppingCart',
  'User',
  'Fold',
  'Expand',
  'ArrowDown',
  'Money',
  'House'
]

requiredIcons.forEach(iconName => {
  if (!app._context.components[iconName]) {
    app.component(iconName, ElementPlusIconsVue[iconName])
  }
})

app.use(ElementPlus)
app.use(createPinia())
app.use(router)
app.mount('#app')
